/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JProductLinkPanel.java
 *
 * Created on 2009-11-3, 13:35:55
 */

package cn.ekuma.epos.qkorder.link;

import cn.ekuma.data.dao.bean.IKeyed;
import cn.ekuma.epos.datalogic.I_DataLogicERP;
import cn.ekuma.epos.order.model.OrderLineVTableModel;
import cn.ekuma.util.SwingUtil;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.gui.MessageInf;
import com.openbravo.data.loader.query.QBFCompareEnum;
import com.openbravo.pos.panels.link.AbstractProductLinkTablePanel;
import com.openbravo.bean.Product;
import com.openbravo.bean.erp.viewbean.OrderLine_V;

/**
 *
 * @author Administrator
 */
public class JProductLinkPanel extends AbstractProductLinkTablePanel<OrderLine_V>{
    private Object[] filterProp;
    /** Creates new form JProductLinkPanel */
    public JProductLinkPanel(I_DataLogicERP dlSales,Object filter) {
        super(dlSales,new OrderLineVTableModel()); 
        Object[] temp=(Object[]) filter;
        int length=temp.length;
        filterProp=new Object[temp.length+2];
        for(int i=0;i<length;i++){
            filterProp[i]=temp[i];
        }
        filterProp[filterProp.length-2]=QBFCompareEnum.COMP_EQUALS;
    }
    
    

    @Override
	public void baseBeanChanged(Product o) {
    	 filterProp[filterProp.length-1]=baseBeanID;
         try {
             tableModel.resert(dlSales.listByFilter(OrderLine_V.class,filterProp));
             SwingUtil.PreferredJXTableColumn(jXTable1);
         } catch (BasicException ex) {
        	 new MessageInf(ex).show(this);
             tableModel.resert(null);
         }
		
	}


	@Override
    public Object createValue() throws BasicException {
        return filterProp;
    }
}
